package ar.com.tallerdos.smartdinner.cocina;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import ar.com.tallerdos.smartdinner.sync.SincronizadorLogin;

public class LoginActivity extends Activity {

	private static Integer loginTipo = 0;
	private static String usuario;
	private static String password;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_user_login);
		
		TextView user = (TextView) findViewById(R.id.userValue);
		TextView pass = (TextView) findViewById(R.id.passwordValue);
		
		user.setText("");
		pass.setText("");
		
		if(loginTipo == 1){
			this.setTitle("Login Cocina");
		}
		else{
			this.setTitle("Login Cafeteria");
		}
	}
	
	public void onBtnClickedLogin(View v)
    { 
		TextView user = (TextView) findViewById(R.id.userValue);
		TextView pass = (TextView) findViewById(R.id.passwordValue);
		
		usuario = user.getText().toString();
		password = pass.getText().toString();
		
		MainActivity.setModoEjecucion(loginTipo);
		MainActivity.getDoingProducts().clear();
		SincronizadorLogin.setContext(this);
		
		SincronizadorLogin dlTask = new SincronizadorLogin(this);
		dlTask.execute();
    }
	
	public static void setLoginTipo(Integer tipo){
		loginTipo = tipo;
	}
	
	public static String getUsuario(){
		return usuario;
	}
	
	public static String getPassword(){
		return password;
	}
	
	public static Integer getLoginTipo(){
		return loginTipo;
	}
}
